package com.bygf.curve.demo;

import com.bygf.curve.Curve;
import com.bygf.curve.XYCurve;
import com.bygf.curve.axis.Axis;
import com.bygf.curve.panel.ChartPanel;
import com.bygf.curve.interfac.AxisChangeListener;
import com.bygf.curve.interfac.MarkChangeListener;
import com.bygf.curve.utils.Scale;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author sunyupei
 */
public class XYCurveDemo4 extends javax.swing.JPanel {

    ChartPanel chartPanel = new ChartPanel();

    /**
     * Creates new form XYCurve
     */
    public XYCurveDemo4() {
        initComponents();
        chartPanel = new ChartPanel("标尺演示及缩放控制", "x", "y", "", false);
        chartPanel.setBounds(1, 1, panel.getWidth(), panel.getHeight());
        chartPanel.getYAxis().setStartValue(0);
        chartPanel.getYAxis().setEndValue(1440);
        chartPanel.getXAxis().setStartValue(0);
        chartPanel.getXAxis().setEndValue(720);
        chartPanel.getTitlePanel().setTitleFont(new Font("宋体", Font.BOLD, 26));
        List<Curve> curveList = new ArrayList<>();
        XYCurve curve = new XYCurve("random");
        for (double i = 0; i <= 720; i += 0.1) {
            double value = Math.sin(Math.toRadians(i)) * i + 1440 / 2;
            curve.addItem(i, value);
        }
        curve.getRender().setShapeVisible(true);
        curveList.add(curve);
        chartPanel.getCurvePanel().setCurveList(curveList);
        panel.add(chartPanel);
        chartPanel.setMarkListener(new MarkChangeListener() {
            @Override
            public void mark1Change(int state) {
                DecimalFormat df = new DecimalFormat("#.#");
                if (state == MarkChangeListener.State_Del) {
                    mark1XText.setText("");
                    mark1YText.setText("");
                    mark1XText.setEnabled(false);
                    mark1YText.setEnabled(false);
                } else {
                    mark1XText.setText(df.format(chartPanel.getCurvePanel().getMark1().getxValue()));
                    mark1YText.setText(df.format(chartPanel.getCurvePanel().getMark1().getyValue()));
                    mark1XText.setEnabled(true);
                    mark1YText.setEnabled(true);
                }
            }

            @Override
            public void mark2Change(int state) {
                DecimalFormat df = new DecimalFormat("#.#");
                if (state == MarkChangeListener.State_Del) {
                    mark2XText.setText("");
                    mark2YText.setText("");
                    mark2XText.setEnabled(false);
                    mark2YText.setEnabled(false);
                } else {
                    mark2XText.setText(df.format(chartPanel.getCurvePanel().getMark2().getxValue()));
                    mark2YText.setText(df.format(chartPanel.getCurvePanel().getMark2().getyValue()));
                    mark2XText.setEnabled(true);
                    mark2YText.setEnabled(true);
                }
            }
        });
        chartPanel.getXAxis().setListener(new AxisChangeListener() {
            
            
            @Override
            public void axisChanged(Axis axis) {
                DecimalFormat df = new DecimalFormat("#");
                xStartText.setText(df.format(axis.getStartValueNow()));
                xEndText.setText(df.format(axis.getEndValueNow()));
            }
        });
        chartPanel.getYAxis().setListener(new AxisChangeListener() {
            
            
            @Override
            public void axisChanged(Axis axis) {
                DecimalFormat df = new DecimalFormat("#");
                yStartText.setText(df.format(axis.getStartValueNow()));
                yEndText.setText(df.format(axis.getEndValueNow()));
            }
        });
        chartPanel.getXAxis().resetAxis();
        chartPanel.getYAxis().resetAxis();
    }

    @Override
    public void setBounds(int x, int y, int width, int height) {
        super.setBounds(x, y, width, height);
        panel.updateUI();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        zoomBtnGroup = new javax.swing.ButtonGroup();
        panel = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        mark2XText = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        mark2YText = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        mark1XText = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        mark1YText = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        zoom1 = new javax.swing.JRadioButton();
        zoom2 = new javax.swing.JRadioButton();
        zoom3 = new javax.swing.JRadioButton();
        zoom0 = new javax.swing.JRadioButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        xStartText = new javax.swing.JTextField();
        xEndText = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        yStartText = new javax.swing.JTextField();
        yEndText = new javax.swing.JTextField();

        panel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        panel.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                panelComponentResized(evt);
            }
        });

        javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel);
        panel.setLayout(panelLayout);
        panelLayout.setHorizontalGroup(
            panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 800, Short.MAX_VALUE)
        );
        panelLayout.setVerticalGroup(
            panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 387, Short.MAX_VALUE)
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("标尺2"));

        jLabel1.setText("X：");

        mark2XText.setEnabled(false);
        mark2XText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                mark2XTextKeyReleased(evt);
            }
        });

        jLabel2.setText("Y：");

        mark2YText.setEnabled(false);
        mark2YText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                mark2YTextKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mark2XText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(82, 82, 82))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mark2YText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(mark2XText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(mark2YText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("标尺1"));

        jLabel5.setText("X：");

        mark1XText.setEnabled(false);
        mark1XText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                mark1XTextKeyReleased(evt);
            }
        });

        jLabel6.setText("Y：");

        mark1YText.setEnabled(false);
        mark1YText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                mark1YTextKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mark1XText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(82, 82, 82))
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mark1YText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(mark1XText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(mark1YText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("缩放"));

        zoomBtnGroup.add(zoom1);
        zoom1.setText("横向");
        zoom1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                zoom1StateChanged(evt);
            }
        });

        zoomBtnGroup.add(zoom2);
        zoom2.setText("纵向");
        zoom2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                zoom2StateChanged(evt);
            }
        });

        zoomBtnGroup.add(zoom3);
        zoom3.setSelected(true);
        zoom3.setText("区域");
        zoom3.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                zoom3StateChanged(evt);
            }
        });

        zoomBtnGroup.add(zoom0);
        zoom0.setText("无");
        zoom0.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                zoom0StateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(zoom1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(zoom3))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(zoom2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(zoom0)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zoom1)
                    .addComponent(zoom3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zoom2)
                    .addComponent(zoom0)))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("横轴"));

        jLabel7.setText("起点：");

        jLabel8.setText("终点：");

        xStartText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                xStartTextKeyReleased(evt);
            }
        });

        xEndText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                xEndTextKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(xStartText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(xEndText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(xStartText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(xEndText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("纵轴"));

        jLabel3.setText("起点：");

        jLabel4.setText("终点：");

        yStartText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                yStartTextKeyReleased(evt);
            }
        });

        yEndText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                yEndTextKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(yStartText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(yEndText, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(yStartText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(yEndText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void panelComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_panelComponentResized
        chartPanel.setBounds(1, 1, panel.getWidth(), panel.getHeight());
    }//GEN-LAST:event_panelComponentResized

    private void mark1XTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mark1XTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(mark1XText.getText().trim());
                chartPanel.getCurvePanel().getMark1().setxValue(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_mark1XTextKeyReleased

    private void mark1YTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mark1YTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(mark1YText.getText().trim());
                chartPanel.getCurvePanel().getMark1().setyValue(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_mark1YTextKeyReleased

    private void mark2XTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mark2XTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(mark2XText.getText().trim());
                chartPanel.getCurvePanel().getMark2().setxValue(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_mark2XTextKeyReleased

    private void mark2YTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mark2YTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(mark2YText.getText().trim());
                chartPanel.getCurvePanel().getMark2().setyValue(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_mark2YTextKeyReleased

    private void zoom1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoom1StateChanged
        if (zoom1.isSelected()) {
            chartPanel.getCurvePanel().setScaleType(Scale.ScaleType_Horizontal);
        }
    }//GEN-LAST:event_zoom1StateChanged

    private void zoom2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoom2StateChanged
        if (zoom2.isSelected()) {
            chartPanel.getCurvePanel().setScaleType(Scale.ScaleType_Vertical);
        }
    }//GEN-LAST:event_zoom2StateChanged

    private void zoom3StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoom3StateChanged
        if (zoom3.isSelected()) {
            chartPanel.getCurvePanel().setScaleType(Scale.ScaleType_Area);
        }
    }//GEN-LAST:event_zoom3StateChanged

    private void zoom0StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoom0StateChanged
        if (zoom0.isSelected()) {
            chartPanel.getCurvePanel().setScaleType(Scale.ScaleType_None);
        }
    }//GEN-LAST:event_zoom0StateChanged

    private void xStartTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_xStartTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(xStartText.getText().trim());
                chartPanel.getXAxis().setStartValueNow(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_xStartTextKeyReleased

    private void xEndTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_xEndTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(xEndText.getText().trim());
                chartPanel.getXAxis().setEndValueNow(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_xEndTextKeyReleased

    private void yStartTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yStartTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(yStartText.getText().trim());
                chartPanel.getYAxis().setStartValueNow(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_yStartTextKeyReleased

    private void yEndTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yEndTextKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                float value = Float.parseFloat(yEndText.getText().trim());
                chartPanel.getYAxis().setEndValueNow(value);
                chartPanel.getCurvePanel().repaint();
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_yEndTextKeyReleased
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JTextField mark1XText;
    private javax.swing.JTextField mark1YText;
    private javax.swing.JTextField mark2XText;
    private javax.swing.JTextField mark2YText;
    private javax.swing.JPanel panel;
    private javax.swing.JTextField xEndText;
    private javax.swing.JTextField xStartText;
    private javax.swing.JTextField yEndText;
    private javax.swing.JTextField yStartText;
    private javax.swing.JRadioButton zoom0;
    private javax.swing.JRadioButton zoom1;
    private javax.swing.JRadioButton zoom2;
    private javax.swing.JRadioButton zoom3;
    private javax.swing.ButtonGroup zoomBtnGroup;
    // End of variables declaration//GEN-END:variables
}
